package husc.se.ndung.soiphubaimobile;

import android.app.Activity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import java.util.List;

import husc.se.ndung.soiphubaimobile.Entity.CongDoan;
import husc.se.ndung.soiphubaimobile.Entity.MaySanXuat;

/**
 * Created by DungNguyen on 6/16/2015.
 */
public class AdapterMaySanXuat extends ArrayAdapter<MaySanXuat> {
    List<MaySanXuat> lsMaySanXuat;
    int resource;
    Activity context;

    public AdapterMaySanXuat(Activity context, int resource, List<MaySanXuat> objects) {
        super(context, resource, objects);
        this.context = context;
        this.resource = resource;
        this.lsMaySanXuat = objects;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        convertView = context.getLayoutInflater().inflate(resource, null);
        TextView lbNameMaySanXuat = (TextView) convertView.findViewById(R.id.lbNameMaySanXuat);
        TextView lbThongTin = (TextView) convertView.findViewById(R.id.lbThongTinMaySanXuat);
        if (lbNameMaySanXuat != null &&
                lbThongTin != null) {
            lbNameMaySanXuat.setText(lsMaySanXuat.get(position).getTenMaySanXuat());
            lbThongTin.setText(lsMaySanXuat.get(position).getThongTinChung());
        }
        return convertView;
    }
}
